// 用户缓存键名
const INFO_KEY = 'kalpana_user_info'
const SEARCH_RECORD_KEY = 'search_record'

export const getInfo = () => {
  return JSON.parse(localStorage.getItem(INFO_KEY)) || {}
}

export const setInfo = (userInfo) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(userInfo))
}

export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

export const getSearchRecord = () => {
  return JSON.parse(localStorage.getItem(SEARCH_RECORD_KEY)) || []
}

export const setSearchRecord = (searchRecord) => {
  localStorage.setItem(SEARCH_RECORD_KEY, JSON.stringify(searchRecord))
}

export const removeSearchRecord = () => {
  localStorage.removeItem(SEARCH_RECORD_KEY)
}
